# -*- coding: utf-8 -*-
"""
@Time ： 2025/8/28 14:53
@Auth ： 李天天
"""
import time

from Common.browser_config import quick_start
from PageObjects.Mine_Page import MinePage
from PageObjects.Main_Page import MainPage
from PageObjects.Player_Page import PlayerPage

pw, browser, context, page = quick_start(auto_login=True)

DEBUG = False
do_mainpage = MainPage(page)
do_minepage = MinePage(page)
do_playerpage = PlayerPage(page)


def step_01():
    print("开始执行操作--1")
    i = 1 if DEBUG else 30
    for i in range(i):
        do_mainpage.click_first_movie()
        time.sleep(8)
        do_playerpage.click_back()
        time.sleep(3)


def step_02():
    print("开始执行操作--2")
    i = 1 if DEBUG else 10
    do_mainpage.click_channel("电视剧")
    do_mainpage.click_first_movie()
    time.sleep(8)
    for i in range(i):
        do_playerpage.click_seekbar_by_percentage(0.2)
        time.sleep(7)
        do_playerpage.click_seekbar_by_percentage(0.6)
        time.sleep(7)
        do_playerpage.click_seekbar_by_percentage(0.8)
        time.sleep(7)
        do_playerpage.click_seekbar_by_percentage(0.2)
        time.sleep(7)
        do_playerpage.click_seekbar_by_percentage(0.6)
        time.sleep(7)
        do_playerpage.click_seekbar_by_percentage(0.8)
        time.sleep(7)
    do_playerpage.click_back()


def step_03():
    print("开始执行操作--3")
    i = 1 if DEBUG else 10
    do_mainpage.click_channel("电视剧")
    do_mainpage.click_first_movie()
    time.sleep(8)
    for i in range(i):
        for index in range(3):
            do_playerpage.click_chioce_episode()
            time.sleep(2)
            do_playerpage.click_episode(index + 1)
            time.sleep(5)

    do_playerpage.click_back()

def step_04():
    print("开始执行操作--4")
    i = 1 if DEBUG else 10
    do_mainpage.click_channel("电视剧")
    do_mainpage.click_first_movie()
    time.sleep(8)
    for i in range(i):
        for rate in ["2.0X","1.5X","1.25X","0.75X","1.0X"]:
            do_playerpage.click_chioce_rate()
            time.sleep(2)
            do_playerpage.click_rate(rate)
            time.sleep(8)

    do_playerpage.click_back()
def step_05():
    print("开始执行操作--5")
    i = 1 if DEBUG else 10
    do_mainpage.click_channel("电视剧")
    do_mainpage.click_first_movie()
    time.sleep(8)
    for i in range(i):
        for bit in ["高清 1080P ","准高清 720P ","标清 480P ","流畅 360P "]:
            do_playerpage.click_chioce_bit()
            time.sleep(2)
            do_playerpage.click_bit(bit)
            time.sleep(8)

    do_playerpage.click_back()
def run_no_play_scene():
    do_mainpage.goto("https://www.iqiyi.com/iv#/?ver=tesla")
    # do_mainpage.goto("https://www.iqiyi.com/iv0401#/?ver=tesla")
    time.sleep(3)
    step_01()
    step_02()
    step_03()
    step_04()
    step_05()
    time.sleep(20)


if __name__ == '__main__':
    while True:
        run_no_play_scene()
